<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>定时器</title>
</head>
<body>
<h1>0</h1>
<h2>0</h2>
<script>
  let count = 0;
  let num = 0;
  setInterval(f,1000);
  let h1 = document.querySelector("h1");
  let h2 = document.querySelector("h2");
  function f() {
    count++;
    h1.innerText = count;
  }
  let timer = setInterval(function () {
    num++;
    h2.innerText = num;
    if(num == 50) {
      clearInterval(timer);
    }
  },100);
  setTimeout(function () {
      alert("时间到!");
  },3000);
</script>
</body>
</html>